/** @namespace app.model.Platform */
module.exports = app => {
  const {STRING, INTEGER, BOOLEAN} = app.Sequelize;
  const Platform = app.model.define('platform', {
    name: {type: STRING, allowNull: false},
    tag: {type: STRING, allowNull: false, unique: 'tag'},
    num_error: {type: INTEGER, defaultValue: 0}, // 错误数量,
    disabled: {type: BOOLEAN, defaultValue: false},// 禁止抓取和显示
  }, {
    timestamps: false,
    tableName: 'spider_platform',
  });

  Platform.associate = () => {
    Platform.hasMany(app.model.AnchorData);
    Platform.hasMany(app.model.TypeData);
  };

  return Platform;
};